/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Client;

import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class Settings
{
    public static Settings getDefault()
    {
        Settings s = new Settings();
        s.setLoginServerPort(6422);
        s.setLoginServerAddress("127.0.0.1");
        return s;
    }
        
    protected int m_LoginServerPort;
    public int getLoginServerPort()
    {
        return m_LoginServerPort;
    }
    
    public void setLoginServerPort(int value)
    {
        m_LoginServerPort = value;
    }
    
    protected String m_LoginServerAddress;
    public String getLoginServerAddress()
    {
        return m_LoginServerAddress;
    }
    
    public void setLoginServerAddress(String value)
    {
        m_LoginServerAddress = value;
    }

    public void Save(String path) throws FileNotFoundException
    {
        FileOutputStream os = new FileOutputStream(path);
        XMLEncoder encoder = new XMLEncoder(os);
        encoder.writeObject(this);
        encoder.close();
    }
    
    public static Settings Load(String path) throws FileNotFoundException
    {
        FileInputStream os = new FileInputStream(path);
        XMLDecoder decoder = new XMLDecoder(os);
        Settings s = (Settings)decoder.readObject();
        decoder.close();
        return s;
    }
}
